/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.netbrain.dao.impl;

import mx.netbrain.dao.UserDao;
import mx.netbrain.model.User;
import mx.netbrain.util.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Julian
 */
public class UserDaoImpl implements UserDao {

    @Override
    public User findForUser(User user) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        String sql = "select u from User u where username=:user and password=:pass";
        Query query = session.createQuery(sql);
        query.setString("user", user.getUsername());
        query.setString("pass", user.getPassword());
        return (User) query.uniqueResult();
    }
}
